subfile Subfile Subfile to which to apply the formula
statement Statement One line of code or a global procedure
APPLY TO SUBSELECTION applies statement to each subrecord in the current subselection of subfile. The statement may be a simple one-line statement or a call to a global procedure. If the statement modifies a subrecord, the modified subrecord is written to disk only when the parent record is written. If the subselection is empty, APPLY TO SUBSELECTION has no effect.
APPLY TO SUBSELECTION can be used to gather information from the subselection or to modify the subselection.
The following example calculates the total sale price for each invoice line from the number of units and the unit price:
ALL SUBRECORDS ([Invoice]Line) ` Select all subrecords
APPLY TO SUBSELECTION ([Invoice]Line;[Invoice]Line'Total := [Invoice]Line'Price * [Invoice]Line'Units)